﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TData
{
    /// <summary>
    /// Attribute mapping for table columns and class fields
    /// </summary>
    /// <example>
    /// CREATE TABLE [dbo].[CEF_MailList] ( 
    /// [OID]        	bigint IDENTITY(1,1) NOT NULL,
    /// [Mail_Addr]  	nvarchar(50) NULL,
    /// [Send_Type]  	char(1) NULL,
    /// [Mail_Status]	char(1) NULL,
    /// CONSTRAINT [OID] PRIMARY KEY([OID])
    /// )
    /// <code>
    /// public class CEF_MailList
    /// {
    /// [TColumnMap(Ordinal = 1)]
    /// public string Mail_Addr { get; set; }
    /// public string Mail_Status { get; set; }
    /// public string Send_Type { get; set; }
    /// }
    /// </code>
    /// </example>
    [AttributeUsage(AttributeTargets.Property)]
    public class TColumnMapAttribute : Attribute
    {
        /// <summary>
        /// <para>The column name of DB TABLE</para>
        /// <para>If not provided, property name equal to column name in TABLE</para>
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// <para>The column ordinal number of DB TABLE. 0 is first column</para>
        /// <para>If not provided, property ordinal number equal to column ordinal in TABLE</para>
        /// </summary>
        public int Ordinal { get; set; }
        /// <summary>
        /// true for class model only
        /// </summary>
        public bool ModelOnly { get; set; }

        /// <summary>
        /// true is identity column for SQL Server, or autoincremental column for SQLite
        /// </summary>
        public bool IsIdentity { get; set; }

        /// <summary>
        /// true is timestamp column for SQL Server
        /// </summary>
        public bool IsTimestamp { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public TColumnMapAttribute()
        {
            Ordinal = int.MinValue;
        }
    }
}
